package com.ctrip.demo.leetcode;

import java.util.Arrays;

/**
 * @author xs.wu
 */
public class LeetCode1996 {

    public static void main(String[] args) {
        numberOfWeakCharacters(new int[][]{{5,5}, {6,3},{3,6}});
    }

    public static int numberOfWeakCharacters(int[][] properties) {
        int res = 0;
        int len = properties.length;
        Arrays.sort(properties,(o1, o2)->o1[0]==o2[0]?o1[1]-o2[1]:o2[0]-o1[0]);

        int max = -1;
        for(int i = 0; i < len; i ++) {

            if(max > properties[i][1]){
                res++;
            }
            max = Math.max(max, properties[i][1]);

        }

        return res;
    }
}
